Jupyter render matplotlib figures in svg

The vscode-jupyter plugin has deprecated the jupyter.generateSVGPlots option, which only renders matplotlib figures in jpg format by default in vscode. To render svg files, here are some ways:

  1. add jupyter startup commands in settings.json
"jupyter.runStartupCommands": [
		"import matplotlib_inline.backend_inline",
		"_VSCode_matplotLib_FigureFormats = matplotlib_inline.backend_inline.InlineBackend.instance().figure_formats",
		"_VSCode_matplotLib_FigureFormats.add('svg')",
		"matplotlib_inline.backend_inline.set_matplotlib_formats(*_VSCode_matplotLib_FigureFormats)"
	]
  1. use jupyter magic command: %config InlineBackend.figure_formats = ['svg']
  2. use native python code
import matplotlib_inline
matplotlib_inline.backend_inline.set_matplotlib_formats("svg")